<?php
namespace common\helpers;

use Yii;

/**
 * Request常用设置
 * @package yiike\wechat\helpers
 */
class Request
{

    public static function isMobile()
    {
        // 如果有HTTP_X_WAP_PROFILE则一定是移动设备
        if (isset ($_SERVER['HTTP_X_WAP_PROFILE']))
        {
            return true;
        }

        $mobile = array();
        static $mobilebrowser_list ='Mobile|iPhone|Android|WAP|NetFront|JAVA|OperasMini|UCWEB|WindowssCE|Symbian|Series|webOS|SonyEricsson|Sony|BlackBerry|Cellphone|dopod|Nokia|samsung|PalmSource|Xphone|Xda|Smartphone|PIEPlus|MEIZU|MIDP|CLDC';
        //note 获取手机浏览器
        if(preg_match("/$mobilebrowser_list/i", $_SERVER['HTTP_USER_AGENT'], $mobile)) {
            return true;
        }
    }
    /**
     * 是否微信浏端
     * @return bool
     */
    public static function isWeixin()
    {
        return strpos(strtolower(@$_SERVER['HTTP_USER_AGENT']), 'micromessenger') !== FALSE;
    }
    
    public static function isIphone()
    {
        return (bool) strpos(strtolower(@$_SERVER['HTTP_USER_AGENT']), 'iphone');
    }

}